import { http } from "@/utils/http";

/**
 数据字典接口
 **/
export const queryDictData = (data?: any) => {
  if (data?.typeCode === "ERC_FACTORY_AREA") {
    // 厂区隔离，HSE地块数据改为，根据当前厂区及本地储存的hseFacAreaList获取
    const facCode = localStorage.getItem("facCode");
    const hseFacAreaList = localStorage.getItem("hseFacAreaList");
    if (facCode && hseFacAreaList) {
      const arr = JSON.parse(hseFacAreaList).filter(item => item.parentCode === facCode);
      const newHseFacAreaList = arr.map(item => ({ ...item, value: item.code, id: item.code }));
      return newHseFacAreaList;
    }
    return [];
  } else {
    return http.request<Array<any>>("post", "/account/api/v1/publish/dictItem/queryListByTypeCode", {
      data
    });
  }
};

/**
 文件接口
 **/
// 删除文件接口
export const deleteFile = (data?: object) => {
  return http.request("post", "/sharing/api/v1/file/delete", {
    data
  });
};
